unit uDZDataExchange;

interface

uses
  Classes, uDZSysUtils;

type
  IDzDataExchangeServer = interface;

  IDzDataExchangeTunnel = interface(IDzBaseInterface)
    function Write(buf: Pointer; len: Integer): Integer;
    function Read(buf: Pointer; len: Integer): Integer;
    function WriteStream(stream: TStream; len: Integer): Integer;
    function ReadStream(stream: TStream; len: Integer): Integer;
    function Skip(len: Integer): Integer;
    procedure Open;
    procedure Close;
    function GetConnected: Boolean;
    procedure SetConnected(const Value: Boolean);
    function GetGuid: AnsiString;
    procedure SetGuid(const value: AnsiString);
    property Connected: Boolean read GetConnected write SetConnected;
    property Guid: AnsiString read GetGuid write SetGuid;  
  end;

  IDzDataExchangeEventHandler = interface(IDzBaseInterface)
    procedure OnConnected(const Exchange: IDzBaseInterface;
      const tunnel: IDzDataExchangeTunnel);
    procedure OnData(const Exchange: IDzBaseInterface;
      const tunnel: IDzDataExchangeTunnel);
    procedure OnDisconnected(const exchange: IDzBaseInterface;
      const tunnel: IDzDataExchangeTunnel);
  end; 

  IDzDataExchangeServer = interface(IDzBaseInterface)
    function GetActive: Boolean;
    procedure SetActive(value: Boolean);
    function GetEventHandler: IDzDataExchangeEventHandler;
    procedure SetEventHandler(const value: IDzDataExchangeEventHandler);
    property Active: Boolean read GetActive write SetActive;
    property EventHandler: IDzDataExchangeEventHandler
      read GetEventHandler write SetEventHandler;
  end;

  IDzDataExchangeClient = interface(IDzBaseInterface)
    function GetActive: Boolean;
    procedure SetActive(value: Boolean);
    function ConnectServer(
      const serverAttr: TNameValueArray): IDzDataExchangeTunnel;
    property Active: Boolean read GetActive write SetActive;
  end;

implementation

end.
